package com.jianglin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jianglin.mapper.HouseMapper;
import com.jianglin.model.House;
import com.jianglin.service.IHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
public class HouseServiceImpl implements IHouseService {
    @Resource
    private HouseMapper houseMapper;

    @Override
    public PageInfo<House> findHouseAll(Integer page, Integer pageSize, String numbers) {
        PageHelper.startPage(page, pageSize);
        List<House> list = houseMapper.findHouseAll(numbers);
        return new PageInfo<>(list);
    }

    @Override
    public int add(House house) {
        return houseMapper.insert(house);
    }

    @Override
    public int delete(Integer id) {
        return houseMapper.deleteById(id);
    }

    @Override
    public int updateData(House house) {
        return houseMapper.updateById(house);
    }

    @Override
    public House findById(Integer id) {
        return houseMapper.selectById(id);
    }

    @Override
    public List<House> findList() {
        // 调用 Mapper 层的方法获取所有房屋列表
        return houseMapper.selectList();
    }

    @Override
    public House queryHouseById(Integer houId) {
        return houseMapper.selectById(houId);
    }}
